package tests.collectionTests;

import java.util.*;

public class HashSetTest {
    public static void main(String[] args) {
        Set<String> hashSet;
        Scanner scanner = new Scanner(System.in);
        System.out.println("[Hash Set]||Tree Set");
        String temp=scanner.nextLine();
        if (temp == null||temp.isEmpty()) {
            System.out.println("Hash");
            hashSet = new TreeSet<>();
        }
        else {
            System.out.println("Tree");
            hashSet = new HashSet<>();
        }

        while (true) {
            temp = scanner.nextLine();
            if (temp == null || temp.length() == 0)
                break;
            if (!hashSet.add(temp))
                System.out.println(temp + " already exists");
        }
        Iterator<String> iterator=new LinkedList<>(hashSet).iterator();
        int i=0;
        while (iterator.hasNext()){
            System.out.println("String "+ ++i +":"+iterator.next());
        }
    }
}
